<?php

/**
 * JingYao-backend
 *
 * @link     https://gitee.com/wang-zhihui-release/jingyao-backend
 * @apiDocument https://gitee.com/wang-zhihui-release/jingyao-backend/wikis/
 */

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->id();
            $table->string('name')->default('');
            $table->string('wx_nick_name')->default('');
            $table->string('phone', 20)->nullable();
            $table->string('password')->nullable()->comment('微信登陆不需要密码');
            $table->string('sex', 5)->default(0)->comment('1: man / 2:woman');
            $table->string('avatar')->default('')->comment('头像');
            $table->string('wx_openid')->nullable();
            $table->string('wx_unionid')->nullable();
            $table->tinyInteger('role')->default(1)->comment('1: user / 2: super Admin');
            $table->tinyInteger('admin_role_id')->default(0)->comment('后台管理员角色 如果为0则不是管理员');
            $table->tinyInteger('identity')->default(0)->comment('1: 流动人口 2: 房东 3: 其他');
            $table->tinyInteger('is_company')->default(0)->comment('是否为公司身份 1 是 2 不是');
            $table->tinyInteger('password_question_type')->default(0)->comment('密保问题类型');
            $table->string('password_question_answer')->default(0)->comment('密保问题答案');
            $table->tinyInteger('login_status')->default(1)->comment('1: 可以登陆 2: 封禁');
            $table->tinyInteger('check_status')->default(0)->comment('用户信息审核状态 1: 通过 2: 拒绝 3: 审核中 4: 草稿');
            $table->rememberToken();
            $table->timestamps();
            $table->softDeletes();
            $table->index('phone');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}
